package com.xieyong.leetcode;

public class Leetcode3202 {

    public static void main(String[] args) {
        Leetcode3202 leetcode3202 = new Leetcode3202();
        int[] nums = {1,4,2,3,1,4};
        int k = 4;
        int i = leetcode3202.maximumLength(nums, k);
        System.out.println(i);
    }



    public int maximumLength(int[] nums, int k) {
        int ans = 0;
        int[][] dp = new int[k][k];
        for (int num : nums) {
            num %= k;
            for (int i = 0; i < k; i++) {
                dp[i][num] = dp[num][i] + 1;
                ans = Math.max(ans, dp[i][num]);
            }

        }
        return ans;
    }
}
